﻿@{
    ViewBag.Title = "异常日志";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">异常日志列表</h3>
                <div class="box-tools">
                    <div class="input-group" style="width: 250px;">
                        <input type="text" class="form-control input-sm" placeholder="请输入名称进行模糊查询...">
                        <div class="input-group-btn">
                            <a class="btn btn-sm btn-default"><i class="fa fa-search"></i></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-body no-padding">
                <div class="mailbox-controls">
                    <div class="btn-group" id="partial_button_toolbar">
                        @{ Html.RenderPartial("~/Areas/Common/Views/Shared/_PartialButton.cshtml"); }
                    </div>
                    <a data-toggle="tooltip" title="刷新" class="btn btn-default btn-sm"><i class="fa fa-refresh">刷新</i></a>
                </div>
                <div class="mailbox-jqgrid">
                    <table id="list"></table>
                    <div id="pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="detailDiv" style="overflow: auto;display: none">
    <table class="edit-table">
        <tbody>
        <tr>
            <th>
                异常时间：
            </th>
            <td>
                <label id="CreateTime"/>
            </td>
        </tr>
        <tr>
            <th>
                登录名：
            </th>
            <td>
                <label id="CreateUserCode"/>
            </td>
        </tr>
        <tr>
            <th>
                真实姓名：
            </th>
            <td>
                <label id="CreateUserName"/>
            </td>
        </tr>
        <tr>
            <th>
                错误信息：
            </th>
            <td>
                <label id="Message"/>
            </td>
        </tr>
        <tr>
            <th>
                堆栈信息：
            </th>
            <td>
                <label id="StackTrace"/>
            </td>
        </tr>
        <tr>
            <th>
                内部异常：
            </th>
            <td>
                <label id="InnerException"/>
            </td>
        </tr>
        <tr>
            <th>
                异常类型：
            </th>
            <td>
                <label id="ExceptionType"/>
            </td>
        </tr>
        <tr>
            <th>
                请求Url：
            </th>
            <td>
                <label id="RequestUrl"/>
            </td>
        </tr>
        <tr>
            <th>
                浏览器信息：
            </th>
            <td>
                <label id="UserAgent"/>
            </td>
        </tr>
        <tr>
            <th>
                请求方式：
            </th>
            <td>
                <label id="HttpMethod"/>
            </td>
        </tr>
        <tr>
            <th>
                请求数据：
            </th>
            <td>
                <label id="RequestData"/>
            </td>
        </tr>
        <tr>
            <th>
                服务器：
            </th>
            <td>
                <label id="ServerHost"/>
            </td>
        </tr>
        <tr>
            <th>
                客户端：
            </th>
            <td>
                <label id="ClientHost"/>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<script type="text/javascript">
    var $grid,
        height;

    function initGird() {
        $grid = $("#list").jgridview(
        {
            loadonce: false,
            url: '/System/Log/GetPagingExceptionLog',
            colModel: [
                { name: "ExceptionLogId", hidden: true },
                { label: "登录名", name: "CreateUserCode", width: 100 },
                { label: "真实姓名", name: "CreateUserName", width: 100 },
                { label: "异常时间", name: "CreateTime", align: "center", width: 130, formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, formatter: 'date' },
                { label: "错误信息", name: "Message", width: 350 },
                { label: "请求地址", name: "RequestUrl", width: 350 },
                { label: "客户端", name: "ClientHost", width: 140 }
            ],
            shrinkToFit: true,
            sortname: "CreateTime",
            height: height,
            sortorder: "desc",
            subGrid: true,
            subGridRowExpanded: function (subgridId, rowId) {
                var rowDatas = $grid.jqGrid('getRowData', rowId);
                if (typeof (rowDatas["ExceptionLogId"]) != "undefined") {
                    UtilAjaxPost("/System/Log/GetExceptionLogById", { id: rowDatas["ExceptionLogId"] },
                        function (val) {
                            $("#detailDiv").find('label').each(function () {
                                var $this = $(this), id = $this.attr('id');
                                (val[id] && typeof (val[id]) === 'string') && $this.text(val[id]);
                            });
                        }
                    );
                } else {
                    $("#detailDiv label").html("");
                }
                $("#" + subgridId).html($("#detailDiv").html());
            }
        });
    }

    $(function () {
        height = UtilWindowHeightWidth().WinH - 319;
        initGird();
        $('#datepicker').datepicker({
            autoclose: true
        });
    });
</script>




